package com.douqu.game.core.config.battle;

import com.douqu.game.core.config.common.CommonData;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.factory.ConstantFactory;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.factory.LoadFactory;
import com.douqu.game.core.util.LoadUtils;
import com.douqu.game.core.util.LogUtils;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-04-12 11:42
 */
public class AIConfig extends GameObject {

    /**
     * 类型
     * 1.定时放技能
     */
    public int type;

    /**
     * 根据类型，格式不同
     * 1. 时间;技能ID|时间;技能ID
     */
    public String value;
    /**
     * 定时技能类型数据
     */
    public CommonData[] timeSkillAry;

    @Override
    public boolean check()
    {
        if(type == ConstantFactory.AI_TYPE_TIME_SKILL)
        {
            timeSkillAry = LoadUtils.loadCommonDataToArray("value", value);
            for(CommonData commonData : timeSkillAry)
            {
                if(DataFactory.getInstance(LoadFactory.isTestLoad()).getGameObject(DataFactory.SKILL_KEY, commonData.value) == null)
                {
                    LogUtils.error("Load AIConfig check value is error -> " + value + " id:" + id);
                    return false;
                }
            }
            return true;
        }
        return super.check();
    }

    @Override
    public boolean setVariable(String key, String value)
    {
        if("value".equals(key))
        {
            this.value = value;
            return true;
        }
        else
            return super.setVariable(key, value);
    }
}
